package com.shixun.service.Impl;

import com.shixun.mapper.BusManageMapper;
import com.shixun.pojo.TbBus;
import com.shixun.pojo.TbBusProblem;
import com.shixun.pojo.TbRepairRecord;
import com.shixun.service.BusManageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BusManageServiceImpl implements BusManageService {

    @Resource
    BusManageMapper busManageMapper;

    @Override
    public List<TbBus> selectBusInfo(int busId, String busName, int busStatus, String city,int limit,int offset) {
        return busManageMapper.selectBusInfo(busId,busName,busStatus,city,limit,offset);
    }

    @Override
    public Integer insertBusInfo(String busName, int busStatus, int repairDriverId, String city) {
        Integer i=busManageMapper.insertBusInfo(busName,busStatus,repairDriverId,city);
        if(i>0){

            return i;
        }
        return 0;
    }

    @Override
    public boolean modifyBusInfo(String newBusName, int newBusStatus, int newRepairDriver, String newCity) {
        int rowsAffected = busManageMapper.modifyBusInfo(newBusName,newBusStatus,newRepairDriver,newCity);
        return rowsAffected > 0;
    }

    @Override
    public List<TbBusProblem> selectBrokenBus(int busId) {
        return busManageMapper.selectBrokenBus(busId);
    }

    @Override
    public boolean setStatus1(int busId) {
        int rowsAffected = busManageMapper.setStatus1(busId);
        return rowsAffected > 0;
    }

    @Override
    public boolean setStatus3(int busId) {
        int rowsAffected = busManageMapper.setStatus3(busId);
        return rowsAffected > 0;
    }

    @Override
    public boolean setStatus4(int busId) {
        int rowsAffected = busManageMapper.setStatus4(busId);
        return rowsAffected > 0;
    }

    @Override
    public List<TbRepairRecord> selectRepairBus(int busId) {
        return busManageMapper.selectRepairBus(busId);
    }


}
